<?php

namespace App\Models\Content;

use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Article extends Model
{
    use ModelTrait, SoftDeletes;
    protected $table = 'articles';
    protected $fillable = [
        'sort', 'title', 'thumb', 'desc', 'redirect_url', 'content', 'view_count', 'status', 'is_top'
    ];

    public function category()
    {
        return $this->belongsToMany(Category::class, 'articles_has_category', 'article_id', 'category_id');
    }

    public function tags()
    {
        return $this->belongsToMany(Tags::class, 'articles_has_tags', 'article_id', 'tag_id');
    }
}
